home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 11 / FM Towns Free Software Collection 11.iso / t_os / lib / yotpin / src / yure.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-20  |  2.2 KB  |  107 lines

  1. /*
  2. *    Yamana's Otomeza Plug-in Tool
  3. *        ゆらゆら
  4. *    
  5. *    1995.07.07  乙女座用プラグイン対応版
  6. *    1995.08.18  cos テーブルを使い微妙にびみょ~に高速化
  7. *    
  8. */
  9. #include    "otome_pi.h"
  10. #include    "costbl.h"
  11.  
  12. const char longname[]  = "EFFECT: ゆらゆら";
  13. int            cnfg_max = 3;
  14. PI_CNFG        cnfg[] =
  15.             {    /* 1234567890123456 ,min,max,def,set */
  16.                 { "横 ←   → 縦  " , 0,   2,  0,  0 },
  17.                 { "揺れの幅"        , 4,  64,  4,  4 },
  18.                 { "揺れの大きさ"    , 2,  32,  3,  3 }
  19.             };
  20.  
  21. #define    USE_ENV        PI_SET_ENV
  22. #define    USE_TYPE    PI_EFFC_ALORSL
  23.  
  24. #include    "otome_pi.c"
  25.  
  26.  
  27. /*************** ゆらゆらテーブル作成 *****************/
  28.  
  29. void mk_table( wide,height,tbl )
  30. int     wide,height,*tbl;
  31. {
  32.     int     i;
  33.     double    d;
  34.     
  35.     for( i=0; i<wide; i++ )
  36.     {    
  37. //        d = (double)( height * sin( (double)((_PI * i) / wide) )+0.8);
  38. //        tbl[ i      ] = (int)( d );
  39.         tbl[ i      ] = (height * sin256( (i*128)/wide )+ 0x80)>>8;
  40.         tbl[ wide+i ] = -tbl[i] ;
  41.     }
  42.     
  43. }
  44.  
  45. /****************** ゆらゆら実行 ***********************/
  46.  
  47. void yurayura( mode,fr, wide,tbl )
  48. FRAME    *fr;
  49. int     mode,wide,*tbl;
  50. {
  51.     FRAME    para;
  52.     int     i;
  53.     
  54.     /* ゆらゆら横 */
  55.     if( mode<2 )
  56.     {    para.lupx = fr->lupx ;
  57.         para.rdwx = fr->rdwx ;
  58.         for( i=(fr->lupy); i<=(fr->rdwy) ; i++ )
  59.         {    para.lupy = para.rdwy = i ;
  60.             EGB_partScroll( EgbPtr,0, tbl[ i % wide ],0, ¶ );
  61.         }
  62.     }
  63.     
  64.     /* ゆらゆら縦 */
  65.     if( mode>0 )
  66.     {    para.lupy = fr->lupy ;
  67.         para.rdwy = fr->rdwy ;
  68.         for( i=(fr->lupx); i<=(fr->rdwx) ; i++ )
  69.         {    para.lupx = para.rdwx = i ;
  70.             EGB_partScroll( EgbPtr,0, 0,tbl[ i % wide ], ¶ );
  71.         }
  72.     }
  73.     
  74. }
  75.  
  76.  
  77. /********************************/
  78.  
  79. int APL_exec()
  80. {
  81.     int     wide,height,mode;
  82.     int     *yure_tbl;
  83.     FRAME    fr;
  84.     
  85.     mode  = cnfg[0].val;        /* 0:横 2:縦 1:両方 */
  86.     wide  = cnfg[1].val;        /* 4~64 */
  87.     height= cnfg[2].val;        /* 2~32 */
  88.     
  89.     if( (yure_tbl = (int*)PI_MALLOC( sizeof(int)*(wide*2+1) ))==NULL )
  90.         return PI_ERROR_NO_MEMORY;
  91.     
  92.     mk_table( wide, height, yure_tbl );
  93.     
  94.     fr.lupx = WORD( g_para + 0 );
  95.     fr.lupy = WORD( g_para + 2 );
  96.     fr.rdwx = WORD( g_para + 4 );
  97.     fr.rdwy = WORD( g_para + 6 );
  98.     EGB_writePage( EgbPtr, pi_imge->page );
  99.     
  100.     yurayura( mode, &fr, wide*2,yure_tbl );
  101.     
  102.     PI_FREE( yure_tbl );
  103.     
  104.     return NOERR;
  105. }
  106.  
  107.